import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

/* Layout */
import Layout from "@/layout";

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

// 初始化路由表配置
const conRoutes = [
  {
    path: "/login",
    component: () => import("@/views/login/index"),
    hidden: true,
  },
  {
    path: "/",
    component: Layout,
    redirect: "/dashboard",
    children: [
      {
        path: "dashboard",
        name: "Dashboard",
        component: () => import("@/views/dashboard/index"),
        meta: {
          title: "我的",
          icon: "dashboard",
        },
      },
    ],
  },
  {
    path: "/tongzhi",
    component: Layout,
    alwaysShow: true,
    meta: {
      title: "通知",
      icon: "el-icon-chat-dot-round",
    },
    children: [
      {
        path: "huiyi",
        name: "huiyi",
        hidden: true,
        component: () => import("@/views/tongzhi/huiyi"),
        // hidden: true,
        meta: {
          title: "会议通知",
          icon: "",
        },
      },
      {
        path: "gongzuo",
        name: "gongzuo",
        hidden: true,
        component: () => import("@/views/tongzhi/gongzuo"),
        meta: {
          title: "工作通知",
          icon: "",
        },
      },
      {
        path: "xinxiang",
        name: "xinxiang",
        component: () => import("@/views/tongzhi/xinxiang"),
        meta: { title: "信箱通知" },
      },
      {
        path: "renwu",
        name: "renwu",
        hidden: true,
        component: () => import("@/views/tongzhi/task"),
        meta: {
          title: "任务",
          icon: "",
        },
      },
      {
        path: "tongzhi",
        name: "tongzhi",
        hidden: true,
        component: () => import("@/views/tongzhi/notification"),
        meta: {
          title: "通知",
          icon: "",
        },
      },
      {
        path: "Shishiredian",
        name: "Shishiredian",
        hidden: true,
        component: () => import("@/views/tongzhi/shishiredian"),
        meta: {
          title: "实时热点",
          icon: "",
        },
      },
      {
        path: "shishiredianDetail",
        name: "shishiredianDetail",
        hidden: true,
        component: () => import("@/views/tongzhi/shishiredianDetail"),
        meta: {
          title: "实时热点详情",
          icon: "",
        },
      },
    ],
  },
  {
    path: "/wuziManage",
    component: Layout,
    alwaysShow: true,
    meta: {
      title: "物资",
      icon: "el-icon-s-platform",
      roles: ["admin", "editor"],
    },
    children: [
      {
        path: "caigoushenqing",
        name: "wuziManage1",
        component: () => import("@/views/wuziManage/caigoushenqing"),
        meta: {
          title: "采购申请单",
          icon: "",
        },
      },
      {
        path: "wuzilingyong",
        name: "wuziManage2",
        component: () => import("@/views/wuziManage/wuzilingyong"),
        meta: {
          title: "物资领用",
          icon: "",
        },
      },
    ],
  },
  {
    path: "/jiaqingManage",
    component: Layout,
    alwaysShow: true,
    meta: {
      title: "假勤",
      icon: "el-icon-s-flag",
    },
    children: [
      {
        path: "qingjia",
        name: "jiaqingManage1",
        component: () => import("@/views/jiaqingManage/qingjia"),
        meta: {
          title: "请假",
          icon: "",
        },
      },
      {
        path: "chuchai",
        name: "jiaqingManage2",
        component: () => import("@/views/jiaqingManage/chuchai"),
        meta: {
          title: "公务出差",
          icon: "",
        },
      },
      {
        path: "jiaban",
        name: "jiaqingManage3",
        component: () => import("@/views/jiaqingManage/jiaban"),
        meta: {
          title: "加班",
          icon: "",
        },
      },
    ],
  },
  {
    path: "/renshiManage",
    component: Layout,
    alwaysShow: true,
    meta: {
      title: "人事",
      icon: "el-icon-user",
    },
    children: [
      {
        path: "userManage",
        name: "renshiManage1",
        hidden: true,
        component: () => import("@/views/renshiManage/userManage"),
        meta: {
          title: "员工管理",
          icon: "",
        },
      },

      {
        path: "gongzi",
        name: "renshiManage4",
        hidden: true,
        component: () => import("@/views/renshiManage/gongzi"),
        meta: {
          title: "工资单",
          icon: "",
        },
      },
      {
        path: "ruzhiApply",
        name: "renshiManage5",
        hidden: true,
        component: () => import("@/views/renshiManage/ruzhiApply"),
        meta: {
          title: "入职申请",
          icon: "",
        },
      },
      {
        path: "zhuanzhengApply",
        name: "renshiManage6",
        hidden: true,
        component: () => import("@/views/renshiManage/zhuanzhengApply"),
        meta: {
          title: "转正申请",
          icon: "",
        },
      },
      {
        path: "lizhiApply",
        name: "renshiManage7",
        component: () => import("@/views/renshiManage/lizhiApply"),
        meta: {
          title: "离职交接",
          icon: "",
        },
      },
    ],
  },
  {
    path: "/xingzhengManage",
    component: Layout,
    alwaysShow: true,
    meta: {
      title: "行政",
      icon: "el-icon-s-check",
    },
    children: [
      {
        path: "duban",
        name: "xingzhengManage1",
        component: () => import("@/views/xingzhengManage/duban"),
        meta: {
          title: "督办单",
          icon: "",
        },
      },
      {
        path: "jiaripaiban",
        name: "xingzhengManage2",
        hidden: true,
        component: () => import("@/views/xingzhengManage/jiaripaiban"),
        meta: {
          title: "排班",
          icon: "",
        },
      },
      {
        path: "yongyin",
        name: "xingzhengManage3",
        component: () => import("@/views/xingzhengManage/yongyin"),
        meta: {
          title: "用印申请",
          icon: "",
        },
      },
      {
        path: "yongche",
        name: "xingzhengManage4",
        component: () => import("@/views/xingzhengManage/yongche"),
        meta: {
          title: "用车申请",
          icon: "",
        },
      },
      {
        path: "jiayou",
        name: "xingzhengManage5",
        component: () => import("@/views/xingzhengManage/jiayou"),
        meta: {
          title: "车辆加油",
          icon: "",
        },
      },
      {
        path: "huiyishi",
        name: "xingzhengManage6",
        component: () => import("@/views/xingzhengManage/huiyishi"),
        meta: {
          title: "会议室申请",
          icon: "",
        },
      },
      {
        path: "jiedaidan",
        name: "xingzhengManage7",
        hidden: true,
        component: () => import("@/views/xingzhengManage/jiedaidan"),
        meta: {
          title: "接待单申请",
          icon: "",
        },
      },
      {
        path: "kanban",
        name: "KSHKB",
        component: () => import("@/views/xingzhengManage/kanban"),
        meta: {
          title: "可视化看板",
          icon: "",
        },
      },
      {
        path: "paizuo",
        name: "ZNPZ",
        component: () => import("@/views/xingzhengManage/paizuo"),
        meta: {
          title: "智能排座",
          icon: "",
        },
      },
      {
        path: "qiandao",
        name: "QDDP",
        component: () => import("@/views/xingzhengManage/qiandao"),
        meta: {
          title: "签到大屏",
          icon: "",
        },
      },
    ],
  },
  {
    path: "/fawuManage",
    component: Layout,
    alwaysShow: true,
    hidden: false,
    meta: {
      title: "法务",
      icon: "el-icon-s-order",
    },
    children: [
      {
        path: "hetong",
        name: "fawuManage1",
        hidden: true,
        component: () => import("@/views/fawuManage/hetong"),
        meta: {
          title: "合同审批",
          icon: "",
        },
      },
      {
        path: "zhaobiaowenjian",
        name: "fawuManage2",
        hidden: true,
        component: () => import("@/views/fawuManage/zhaobiaowenjian"),
        meta: {
          title: "招标文件审核",
          icon: "",
        },
      },
    ],
  },
  {
    path: "/gongwenManage",
    component: Layout,
    alwaysShow: true,
    hidden: false,
    meta: {
      title: "公文",
      icon: "el-icon-collection",
    },
    children: [
      {
        path: "gongwenchuanyue",
        name: "gongwenManage1",
        hidden: true,
        component: () => import("@/views/gongwenManage/gongwenchuanyue"),
        meta: {
          title: "传阅文件",
          icon: "",
        },
      },
      {
        path: "gongwenliuzhuan",
        name: "gongwenManage2",
        hidden: true,
        component: () => import("@/views/gongwenManage/gongwenliuzhuan"),
        meta: {
          title: "公文流转",
          icon: "",
        },
      },
      {
        path: "xinjianfawen",
        name: "xinjianfawen",
        hidden: true,
        component: () => import("@/views/gongwenManage/xinjianfawen"),
        meta: {
          title: "新建事项",
          icon: "",
        },
      },
      {
        path: "xuanchuanbaodao",
        name: "xuanchuanbaodao",
        hidden: true,
        component: () => import("@/views/gongwenManage/xuanchuanbaodao"),
        meta: {
          title: "宣传报道",
          icon: "",
        },
      },
      {
        path: "neibufawen",
        name: "gongwenManage3",
        hidden: true,
        component: () => import("@/views/gongwenManage/neibufawen"),
        meta: {
          title: "内部发文",
          icon: "",
        },
      },
      {
        path: "lishigongwen",
        name: "gongwenManage4",
        hidden: true,
        component: () => import("@/views/gongwenManage/lishigongwen"),
        meta: {
          title: "历史公文",
          icon: "",
        },
      },
      {
        path: "gongwenshoucang",
        name: "gongwenManage5",
        hidden: true,
        component: () => import("@/views/gongwenManage/gongwenshoucang"),
        meta: {
          title: "公文收藏",
          icon: "",
        },
      },
    ],
  },
  {
    path: "/sysManage",
    component: Layout,
    alwaysShow: true,
    hidden: false,
    meta: {
      title: "系统",
      icon: "el-icon-s-tools",
    },
    children: [
      {
        path: "positionCon",
        name: "sysManage1",
        hidden: true,
        component: () => import("@/views/sysManage/positionCon"),
        meta: {
          title: "岗位配置",
          icon: "",
        },
      },
      {
        path: "roleCon",
        name: "sysManage10",
        hidden: true,
        component: () => import("@/views/sysManage/roleCon"),
        meta: {
          title: "角色配置",
          icon: "",
        },
      },
      {
        path: "userGroup",
        name: "sysManage11",
        hidden: true,
        component: () => import("@/views/sysManage/userGroup"),
        meta: {
          title: "人员分组",
          icon: "",
        },
      },
      {
        path: "departmentCon",
        name: "renshiManage2",
        hidden: true,
        component: () => import("@/views/sysManage/departmentCon"),
        meta: {
          title: "部门配置",
          icon: "",
        },
      },
      {
        path: "jiejiariCon",
        name: "sysManage3",
        hidden: true,
        component: () => import("@/views/sysManage/jiejiariCon"),
        meta: {
          title: "节假日配置",
        },
      },
      {
        path: "cheliangCon",
        name: "sysManage4",
        hidden: true,
        component: () => import("@/views/sysManage/cheliangCon"),
        meta: {
          title: "车辆配置",
        },
      },
      {
        path: "documentType",
        name: "documentType",
        hidden: true,
        component: () => import("@/views/sysManage/documentType"),
        meta: {
          title: "公文类型",
        },
      },
      {
        path: "huiyishiCon",
        name: "sysManage5",
        hidden: true,
        component: () => import("@/views/sysManage/huiyishiCon"),
        meta: {
          title: "会议室配置",
        },
      },
      {
        path: "qingjiaCon",
        name: "sysManage6",
        hidden: true,
        component: () => import("@/views/sysManage/qingjiaCon"),
        meta: {
          title: "请假配置",
        },
      },
      {
        path: "yinzhangCon",
        name: "sysManage7",
        hidden: true,
        component: () => import("@/views/sysManage/yinzhangCon"),
        meta: {
          title: "印章配置",
        },
      },
      {
        path: "eveCon",
        name: "sysManage8",
        hidden: true,
        component: () => import("@/views/sysManage/eveCon"),
        meta: {
          title: "流程配置",
        },
      },
      {
        path: "rootCon",
        name: "sysManage9",
        hidden: true,
        component: () => import("@/views/sysManage/rootCon"),
        meta: {
          title: "系统权限",
        },
      },
    ],
  },
  {
    path: "/performanceManage",
    component: Layout,
    alwaysShow: true,
    meta: {
      title: "绩效管理",
      icon: "el-icon-s-order",
    },
    children: [
      {
        path: "createTemplate",
        name: "createTemplates",
        component: () => import("@/views/performanceManage/createTemplate"),
        meta: {
          title: "建立考核模板",
          icon: "",
        },
      },
      {
        path: "assessment",
        name: "assessments",
        component: () => import("@/views/performanceManage/assessment"),
        meta: {
          title: "发起考核",
          icon: "",
        },
      },
      {
        path: "filling",
        name: "fillings",
        component: () => import("@/views/performanceManage/filling"),
        meta: {
          title: "考核填报",
          icon: "",
        },
      },
      {
        path: "estimate",
        name: "estimates",
        component: () => import("@/views/performanceManage/estimate"),
        meta: {
          title: "考核评估",
          icon: "",
        },
      },

      {
        path: "dataScreening",
        name: "dataScreenings",
        component: () => import("@/views/performanceManage/dataScreening"),
        meta: {
          title: "考核数据总览",
          icon: "",
        },
      },
      {
        path: "Notification",
        name: "Notifications",
        component: () => import("@/views/performanceManage/Notification"),
        meta: {
          title: "发布绩效通知",
          icon: "",
        },
      },
      {
        path: "management",
        name: "managements",
        component: () => import("@/views/performanceManage/management"),
        meta: {
          title: "部门绩效管理",
          icon: "",
        },
      },
      {
        path: "announcement",
        name: "announcements",
        component: () => import("@/views/performanceManage/announcement"),
        meta: {
          title: "公告管理",
          icon: "",
        },
      },
    ],
  },
  {
    path: "/partyManage",
    component: Layout,
    alwaysShow: true,
    hidden: false,
    meta: {
      title: "党建",
      icon: "el-icon-s-tools",
    },
    children: [
      {
        path: "dangzuzhi",
        name: "partyManage1",
        component: () => import("@/views/partyManage/dangzuzhi"),
        meta: { title: "党组织机构" },
      },
      {
        path: "partyRole",
        name: "partyManage2",
        component: () => import("@/views/partyManage/partyRole"),
        meta: { title: "党组织角色" },
      },
      {
        path: "partyUser",
        name: "partyManage3",
        component: () => import("@/views/partyManage/partyUser"),
        meta: { title: "党组织用户" },
      },
      {
        path: "partyDues",
        name: "partyManage4",
        component: () => import("@/views/partyManage/partyDues"),
        meta: { title: "党费收缴" },
      },
      {
        path: "questionBank",
        name: "partyManage5",
        component: () => import("@/views/partyManage/question/index"),
        meta: { title: "题库" },
      },
      {
        path: "examPaper",
        name: "partyManage6",
        component: () => import("@/views/partyManage/examPaper/index"),
        meta: { title: "试卷管理" },
      },
      {
        path: "marking",
        name: "partyManage7",
        component: () => import("@/views/partyManage/marking/index"),
        meta: { title: "阅卷" },
      },
      {
        path: "education",
        name: "learnEducation",
        component: () => import("@/views/partyManage/learnEducation/index"),
        meta: { title: "教育学习" },
      },
      {
        path: "publicize",
        name: "publicize",
        component: () => import("@/views/partyManage/publicize/index"),
        meta: { title: "宣传通讯管理" },
      },
      {
        path: "activityLedger",
        name: "activityLedger",
        component: () => import("@/views/partyManage/activityLedger/index"),
        meta: { title: "党员活动台账" },
      },
      {
        path: "politicalActivity",
        name: "politicalActivity",
        component: () => import("@/views/partyManage/politicalActivity/index"),
        meta: { title: "党群活动" },
      },
      {
        path: "mailbox",
        name: "partyManage8",
        component: () => import("@/views/partyManage/mailbox"),
        meta: { title: "书记信箱" },
      },
    ],
  },
   // 学习教育
  // {
  //   path: '/learnEducation',
  //   component: Layout,
  //   alwaysShow: true,
  //   hidden: false,
  //   meta: {
  //     title: '学习教育',
  //     icon: 'el-icon-document'
  //   },
  //   children: [{
  //     path: 'education',
  //     name: 'uploadFile',
  //     component: () => import('@/views/learnEducation'),
  //     meta: { title: '上传文件' }
  //   }]
  // },
  {
    path: "/projectManagement",
    component: Layout,
    alwaysShow: true,
    hidden: false,
    meta: {
      title: "科研项目管理",
      icon: "el-icon-folder-opened",
    },
    children: [
      {
        path: "openReport",
        name: "openEntrance",
        component: () =>
          import("@/views/projectManagement/approval/openEntrance"),
        meta: { title: "开放申报" },
      },
      {
        path: "approvalInitiateDeclaration",
        name: "initiateDeclaration",
        component: () =>
          import("@/views/projectManagement/approval/initiateDeclaration"),
        meta: { title: "申报立项" },
      },
      {
        path: "selfProject/:id?",
        // path: 'selfProject',
        name: "selfProject",
        component: () =>
          import("@/views/projectManagement/approval/selfProject"),
        meta: { title: "自立项目申报流程" },
      },
      {
        path: "outsideProject/:id?",
        name: "outsideProject",
        component: () =>
          import("@/views/projectManagement/approval/outsideProject"),
        meta: { title: "项目申报流程" },
      },
      {
        path: "approveReport",
        name: "review",
        component: () => import("@/views/projectManagement/approval/review"),
        meta: { title: "申报审核" },
      },
      {
        path: "processProjectList",
        name: "projectList",
        component: () =>
          import("@/views/projectManagement/process/project/index"),
        meta: { title: "项目列表" },
      },
      {
        path: "processDataManagement",
        name: "dataManagement",
        component: () =>
          import("@/views/projectManagement/process/dataManagement"),
        meta: { title: "资料管理" },
      },
      {
        path: "processDataStatistics",
        name: "dataStatistics",
        component: () =>
          import("@/views/projectManagement/process/dataStatistics"),
        meta: { title: "数据统计" },
      },
      {
        path: "projectLibrary",
        name: "projectLibrary",
        component: () => import("@/views/projectManagement/projectLibrary"),
        meta: { title: "项目库" },
      },
      {
        path: "projectForum",
        name: "projectForum",
        component: () => import("@/views/projectManagement/forum"),
        meta: { title: "项目论坛" },
      },
    ],
  },
  {
    path: "/scientific",
    component: Layout,
    alwaysShow: true,
    hidden: false,
    meta: {
      title: "科研管理",
      icon: "el-icon-s-order",
    },
    children: [
      {
        path: "ScientificData",
        name: "ScientificDatas",
        component: () => import("@/views/scientific/ScientificData"),
        meta: {
          title: "科研资料库",
          icon: "",
        },
      },
      {
        path: "ScientificPeople",
        name: "ScientificPeoples",
        component: () => import("@/views/scientific/researchers/index"),
        meta: {
          title: "科研人员管理",
          icon: "",
        },
      },
      {
        path: "ScientificFunding",
        name: "ScientificFundings",
        component: () => import("@/views/scientific/ScientificFunding"),
        meta: {
          title: "科研业务专项资金管理",
          icon: "",
        },
      },
      {
        path: "release",
        name: "releases",
        component: () => import("@/views/scientific/release"),
        meta: { title: "发布科研成果考核", icon: "" },
      },
      {
        path: "Filling",
        name: "Fillings",
        component: () => import("@/views/scientific/Filling"),
        meta: { title: "科研成果考核填报", icon: "" },
      },
      {
        path: "approve",
        name: "approves",
        component: () => import("@/views/scientific/approve"),
        meta: { title: "科研成果考核审批", icon: "" },
      },
    ],
  },
  // 404 page must be placed at the end !!!
  {
    path: "*",
    redirect: "/404",
    hidden: true,
  },
];

// 在这里传入用户开启的页面
// 默认开放页面的，根据权限获得页面追加在userRoutes后面即可

console.log(
  "modify routets -----------------------------------------------------------"
);

// console.log("111111111111111111111",conRoutes1)
/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = conRoutes;

const createRouter = () =>
  new Router({
    // mode: 'hash', // history require service support
    mode: "hash", // history require service support
    scrollBehavior: () => ({
      y: 0,
    }),
    routes: constantRoutes,
  });

const router = createRouter();

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher; // reset router
}
export default router;
